/***************************************************************
|	File:		Game.h
|	Author:		John Gawne
|	Course:		Structure of Game Design
|	Purpose:	Game class controls the SGD wrappers
|				& runs the game state machine
***************************************************************/

#ifndef GAME_H
#define GAME_H


/**************************************************************/
// Forward class declaration
//	- tells the compiler that the type exists
//	- allows us to create pointers or references
class BitmapFont;
class IGameState;

#include "../SGD Wrappers/SGD_Declarations.h"
#include "../SGD Wrappers/SGD_Geometry.h"
#include "../SGD Wrappers/SGD_String.h"
#include "BitmapFont.h"
#include <list>



/**************************************************************/
// Game class
//	- runs the game logic
//	- controls the SGD wrappers
//	- SINGLETON!
//		- there is only ONE instance
//		- global access method (GetInstance)

class Camera;

class Game
{

public:

	class Save
	{
	public:

		unsigned char		SavedSlot ;
		unsigned char		Upgrades[3];
		SGD::String*		Time[3];
		bool				FullScreen;
		int					MusicVolume;
		int					SFXVolume;
		int					ScoreSize;
		std::list<float>	Score;
		~Save()
		{
			for (unsigned short i = 0; i < 3 ; i++)
			{
				delete Time[i];
			}

		}
	};

	/**********************************************************/
	// Singleton Accessors:
	static Game*	GetInstance		( void );
	static void		DeleteInstance	( void );

	
	/**********************************************************/
	// Setup, Play, Cleanup:
	bool Initialize	( int width, int height );
	int	 Main		( void );
	void Terminate	( void );
	
	
	/**********************************************************/
	// Screen Size Accessors:
	int			GetScreenWidth	( void ) const	{ return m_nScreenWidth;	}
	int			GetScreenHeight ( void ) const	{ return m_nScreenHeight;	} 
	Save*		GetSave()				 const	{ return save;				}
	Camera*		GetCamera()				 const	{ return m_pCamera;			}
	BitmapFont* GetFont()				 const	{ return m_pFont;			}

	void	SetCamera(Camera* camera)			{ m_pCamera = camera; }
	// Font Accessor:
	//BitmapFont* GetFont	( void ) const	{	return m_pFont;			}

	
	/**********************************************************/
	// Game State Machine:
	//	- can ONLY be called by the state's Input, Update, or Render methods!!!
	void ChangeState( IGameState* pNewState );


private:
	/**********************************************************/
	// Singleton Object:
	static Game*	s_pInstance;

	Game( void )	= default;		// default constructor
	~Game( void )	= default;		// destructor

	Game( const Game& )				= delete;	// copy constructor
	Game& operator= ( const Game& )	= delete;	// assignment operator

	bool togglescreen = false;
	/**********************************************************/
	// SGD Wrappers
	SGD::AudioManager*		m_pAudio		= nullptr;
	SGD::GraphicsManager*	m_pGraphics		= nullptr;
	SGD::InputManager*		m_pInput		= nullptr;

		
	/**********************************************************/
	// Screen Size
	int						m_nScreenWidth	= 1;
	int						m_nScreenHeight = 1;
	bool					m_bFullScreen;
	

	/**********************************************************/
	// Game Font
	//BitmapFont*				m_pFont			= nullptr;


	/**********************************************************/
	// Current Game State
	IGameState*				m_pCurrState	= nullptr;


	/**********************************************************/
	// Game Time
	unsigned long			m_ulGameTime	= 0;


	Save*		save		= nullptr;
	Camera*		m_pCamera	= nullptr;
	BitmapFont* m_pFont		= nullptr;
	
};

#endif //GAME_H
